import { Upload } from 'antd';
import { observer } from 'mobx-react';
import { userStore } from '../../stores/UserStore';
import { Avatar } from 'antd';
import { settingStore } from '../../stores/SettingStore';

export const AvatarUpload = observer((props: any) => {
    const beforeUpload = (file: any) => {
        settingStore.OssUpload(file);
        return false;
    }

    return (
        <Upload
            name="avatar"
            listType="picture-card"
            className="avatar-uploader"
            showUploadList={false}
            beforeUpload={beforeUpload}
        >
            <Avatar src={userStore.userInfo?.avatar} />
            <div className="mask">
                <div className="change">修改头像</div>
            </div>
        </Upload>
    );
})

